package com.kn.sys.controller;

import com.kn.common.model.R;
import com.kn.sys.dto.IdsDto;
import com.kn.sys.service.PermissionService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RequestMapping("sys/permission")
@RestController
@RequiredArgsConstructor
@CrossOrigin
public class PermissionController {
    private final PermissionService permissionService;
    @GetMapping("right")
    public R getRights(){
        return permissionService.getRights();
    }
    @GetMapping("/rightsByRoleId/{roleId}")
    public R rightsByRoleId(@PathVariable Long roleId){
        return permissionService.rightsByRoleId(roleId);
    }
    @PostMapping("/{roleId}")
    public R savePermission(@PathVariable Long roleId, @RequestBody IdsDto[] idsDtos){
        return permissionService.savePermission(roleId,idsDtos);
    }
@GetMapping("menu")
    public R getMenu(){
        return permissionService.getMenu();
}
}
